## start command: sh run.sh train hdmb51
# export DUMP_GE_GRAPH=2
# export PRINT_MODEL=1
export ASCEND_SLOG_PRINT_TO_STDOUT=0
export ASCEND_GLOBAL_LOG_LEVEL=3
export TF_CPP_MIN_LOG_LEVEL=2

code_dir=${1}
run_mode=${2}
dataset_name=${3}

echo "***mode:${run_mode}, dataset:${dataset_name}"

train_path="${code_dir}/splits_txt/${dataset_name}/${dataset_name}_train_split_1_rawframes.txt"
val_path="${code_dir}/splits_txt/${dataset_name}/${dataset_name}_val_split_1_rawframes.txt"
dataset_path="/cache/${dataset_name}_extracted"

CurrentTime=`date "+%Y-%m-%d-%H-%M-%S"`

if [ ${run_mode} = 'train' ]
then
    resume_path="experiments/ECOfull/ECOfull_kinetics.ckpt"
    python3.7 ${code_dir}/train.py ${dataset_name} ${dataset_path} RGB ${train_path} ${val_path} --epochs 5 2>&1 | tee ${CurrentTime}.log
elif [ ${run_mode} = 'test' ]
then
    resume_path="experiments/201020-144517/ckpt/best.ckpt"
    python3.7 ${code_dir}/test.py ${dataset_name} ${dataset_path} RGB ${train_path} ${val_path} --resume_path ${resume_path}
else
    echo "${run_mode}} mode is not supported."
fi